<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

		<title><?php echo C('WEB_TITLE');?></title>

		<link rel="stylesheet" type="text/css" href="/Public/css/common.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/js/layui/css/layui.css" media="all"/>

		<link rel="stylesheet" href="/Public/js/datepicker/datepicker.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/crm/css/index.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/crm/css/style.css"/>

		<link rel="stylesheet" href="<?php echo C('PC_ICON_HTTP');?>">

		<script type="text/javascript" >

			const moduleName = "<?php echo (MODULE_NAME); ?>";

		</script>

        <link rel="stylesheet" href="/Public/js/viewer/css/viewer.min.css">
		
		<link rel="stylesheet" type="text/css" href="/Public/js/select2/select2.css" media="all"/>

		<script type="text/javascript" src="/Public/js/jquery-1.9.1.min.js"></script>
		
		<script type="text/javascript" src="/Public/js/jquery-ui.min.js"></script>

		<script type="text/javascript" src="/Public/js/cookie/jquery.cookie.js"></script>

		<script type="text/javascript" src="/Public/js/lang/<?php echo (getStrToLower(cookie('think_language'))); ?>.js"></script>

		<script type="text/javascript" src="/Public/js/colorpicker.js"></script>

		<script type="text/javascript" src="/Public/js/layer/layer.js"></script>

		<script type="text/javascript" src="/Public/js/layui/layui.js"></script>

        <script type="text/javascript" src="/Public/js/feeldesk.js"></script>

        <script type="text/javascript" src="/Public/crm/js/index.js"></script>

        <script type="text/javascript" src="/Public/js/jquery.nicescroll.js"></script>

		<script type="text/javascript" src="/Public/js/clipboard.min.js"></script>

		<script type="text/javascript" src="/Public/js/select2/select2.min.js"></script>

		<script type="text/javascript" src="/Public/js/select2/jquery.core.js"></script>

	</head>

<body>

<script type="text/javascript" src="/Public/js/datepicker/datepicker.all.js"></script>

<script type="text/javascript" src="/Public/js/datepicker/moment.min.js"></script>

<script type="text/javascript" src="/Public/js/datepicker/datepicker.en.js"></script>

    <div class="fd-right-main">

        

    <div class="feeldesk-form pd0 ">

		<form action="<?php echo U('customer/create_contacter',['id'=>encrypt($customer_id,'CUSTOMER'),'detailtype'=>encrypt($detailtype,'CUSTOMER'),'wechat'=>$wechat]);?>" class="layui-form" method="post" enctype="multipart/form-data">

        <div class="form-nav">

            <ul>

                <li><a href="javascript:" class="form-tab active"><?php echo L('ADD_CUSTOMER_CONTACT');?></a></li>

				<?php if(!empty($detailtype)): ?><a href="javascript:history.go(-1);" class="feelcrm-cancleBtn fr mt5 mr30"><?php echo l('CANCEL');?></a><?php endif; ?>

				<?php if(!empty($wechat)): ?><a href="javascript:closeLayerOpen();" class="feelcrm-cancleBtn fr mt5 mr30"><?php echo l('CANCEL');?></a><?php endif; ?>

				<a href="javascript:void(0)" class="layui-btn layui-btn-normal feelcrm-commbtn fr mt5 mr10" id="submitForm"><?php echo L('SUBMIT');?></a>

            </ul>

        </div>

        <div class="form-content pt50">
		<?php $t = 0; $ft = 0; $reg = 0; ?>


				 <div class="form-item pb50">

					<?php if(empty($customer_id)): ?><div class="layui-form-item">

							<label class="layui-form-label">

								<span class="red">*</span>

							   <?php echo L('OWNED_CUSTOMER');?>

							</label>

							<div class="layui-input-inline">

								<input type="radio" id="selectCustomerInput" class="layui-input" name="contacter[customer_id]" title="<?php echo L('NO_CUSTOMER_SELECTED');?>" checked value="" readonly />

								<div id="selectCustomer" class="feelcrm-commbtn" ><?php echo L('SELECT_CUSTOMER');?></div>

							</div>

							<i class="layui-icon layui-icon-about intro-icon" data-note="<?php echo L('ENTER_NAME_SEARCH');?>"></i>

						</div><?php endif; ?>

						<?php if(!empty($wechat)): ?><input type="hidden" name="editContacterWechat" value="1" >

							<input type="hidden" name="contacter_edit[wechat]" value="<?php echo ($wechat); ?>" >

							<div class="layui-form-item wechatbox">

								<label class="layui-form-label">

									<span class="red">*</span>

								   <?php echo L('SELECT_CONTACT');?>

								</label>

								<div class="layui-input-inline">

									<select name="contacter_edit[contacter_id]" id="ContacterList" lay-filter="ContacterList" lay-ignore>

										<option value=""><?php echo L('SELECT_CONTACT');?></option>


									</select>

									<script>

										$("#ContacterList").select2();

									</script>

								</div>


							</div>

							<div class="layui-form-item wechatbox">

								<label class="layui-form-label">


								</label>

								<div class="layui-input-inline">

									<a href="javascript:createNewcontacter();" class="layui-btn layui-btn-normal feelcrm-commbtn mt5 mr10"><?php echo L('ADD_CONTACTS');?></a>

								</div>


							</div><?php endif; ?>

                       <?php if(is_array($contacterform)): $i = 0; $__LIST__ = $contacterform;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
					   <?php if(!$vo['role_id'] || in_array($index['role_id'],explode(',',$vo['role_id']))): ?><div class="layui-form-item contacterdefine <?php if(!empty($wechat)): ?>hidden<?php endif; ?>">

                            <label class="layui-form-label">

                                <?php if(($vo["is_required"]) == "0"): ?><span class="red">*</span><?php endif; ?>

                                <?php echo ($vo["form_description"]); ?>

                            </label>

							<?php if(($vo["form_type"]) == "region"): $reg++; ?>

								<?php echo W('Region/getRegion',['contacter_form',$vo['form_name'],$reg]);?>

							<?php else: ?>

                            <div class="layui-input-inline">

                                <?php if(($vo["form_type"]) == "text"): ?><!-- 单行文本框 -->

									<?php if(($vo["form_name"]) == "wechat"): if(!empty($wechat)): ?><input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($wechat); ?>" readonly placeholder="" class="layui-input">

										<?php else: ?>

											<input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" placeholder="" class="layui-input"><?php endif; ?>

									<?php else: ?>

										<input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" placeholder="" class="layui-input"><?php endif; endif; ?>

								 <?php if(($vo["form_type"]) == "phone"): ?><!-- <?php echo L('CELL_PHONE');?> -->
                                    <input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" placeholder="" class="layui-input"><?php endif; ?>

								 <?php if(($vo["form_type"]) == "email"): ?><!-- <?php echo L('MAILBOX');?> -->
                                    <input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" placeholder="" class="layui-input"><?php endif; ?>

								 <?php if(($vo["form_type"]) == "number"): ?><!-- <?php echo L('DIGITAL');?> -->
                                    <input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" placeholder="" class="layui-input"><?php endif; ?>

								<?php if(($vo["form_type"]) == "decimal"): ?><!-- 小数 -->
                                    <input type="text" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" placeholder="" class="layui-input"><?php endif; ?>

                                <?php if(($vo["form_type"]) == "select"): ?><!-- 下拉菜单 -->
                                    <select name="contacter_form[<?php echo ($vo["form_name"]); ?>]">

                                        <option value=""><?php echo ($vo["form_description"]); ?></option>

                                        <?php if(is_array($vo["option"])): foreach($vo["option"] as $key=>$op): ?><option value="<?php echo ($op); ?>"><?php echo ($op); ?></option><?php endforeach; endif; ?>

                                    </select><?php endif; ?>
								
								<?php if(($vo["form_type"]) == "select_text"): $st++; ?>
                                    <!-- 下拉填写 -->
                                    <?php echo W('Update/selectTextForm',['contacter',$vo,$st]); endif; ?>

                                <!-- 时间控件 -->
                                <?php if(($vo["form_type"]) == "date"): $ft++; ?>

                                    <input type='text' name="contacter_form[<?php echo ($vo["form_name"]); ?>]" class="layui-input cursor layui-form-time" id="form_time<?php echo $ft; ?>" placeholder="<?php echo L('SELECT_TIME');?>" ><?php endif; ?>

                                <?php if(($vo["form_type"]) == "checkbox"): ?><!-- 复选框 -->
                                    <?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><input type="checkbox" name="contacter_form[<?php echo ($vo["form_name"]); ?>][]" lay-skin="primary" title="<?php echo ($op); ?>" value="<?php echo ($op); ?>"><?php endforeach; endif; else: echo "" ;endif; endif; ?>

                                <?php if(($vo["form_type"]) == "radio"): ?><!-- 单选框-->
                                    <?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$op): $mod = ($i % 2 );++$i;?><input type="radio" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" value="<?php echo ($op); ?>" title="<?php echo ($op); ?>"><?php endforeach; endif; else: echo "" ;endif; endif; ?>

                                <!-- 文本域 -->
                                <?php if(($vo["form_type"]) == "textarea"): $t++ ?>

                                    <textarea class="layui-textarea layui-hide ticket-textarea" name="contacter_form[<?php echo ($vo["form_name"]); ?>]" id="ticketEditor<?php echo $t; ?>"></textarea><?php endif; ?>

                            </div><?php endif; ?>

                            <?php if(!empty($vo["form_explain"])): ?><i class="layui-icon layui-icon-about intro-icon" data-note="<?php echo ($vo["form_explain"]); ?>"></i><?php endif; ?>

                        </div><?php endif; endforeach; endif; else: echo "" ;endif; ?>

				</div>

        </div>

		</form>

    </div>

	
<div class="hidden hg100 layui-form" id="selectCustomerCon">

	<div class="feeldesk-form pd0 feelcrm-form ">

		<div class="layui-tab">

			<ul class="layui-tab-title">

				<li class="tab-title-name"><?php echo L('CUSTOMER_LIST');?></li>

				<li class="tab-title-btn">

					<a href="javascript:void(0);" class="layui-btn layui-btn-normal titleSubmit" id="selectCustomerSubmit"><?php echo l('SUBMIT');?></a>

					<a href="javascript:void(0);" class="layui-btn layui-btn-normal titleCancel" id="selectCustomerCancel"><?php echo l('CANCEL');?></a>

					<div class="clear"></div>

				</li>

				<form action="" class="fr selectCustomerForm" method="get">

					<input type="hidden" name='customer_auth' value="<?php echo ($customer_view_auth); ?>" />

					<input type="hidden" name='highKeyword[condition]' value="1" />

					<input type="hidden" name='highKeyword[define_form][importance]' />

					<input type="hidden" name='highKeyword[define_form][customer_grade]' />

					<div class="compact-search">

						<i class="iconfont icon-search"></i>

						<input type="text" name="selectCustomerKeyword" value="" placeholder=""/>

						<input type="text" class="hidden" name="" value="" placeholder=""/>

						<a href="javascript:" class="selectCustomerBtn"><?php echo L('SEARCH');?></a>

					</div>

				</form>

				<div class="clear"></div>

			</ul>

		</div>

		<div class="border_b">

			<div class="customer-list-filter select-fiter" data-type="customer_auth">

				<div class="customer-list-filter-tit"><?php echo L('VIEW_RANGE');?></div>

				<?php if(!empty($isCustomerOwnViewAuth)): ?><div class="customer-list-filter-option <?php if(($customer_view_auth) == "own"): ?>active<?php endif; ?>" data-value="own"><?php echo L('PERSONAL');?></div><?php endif; ?>

				<?php if(!empty($isCustomerGroupViewAuth)): ?><div class="customer-list-filter-option <?php if(($customer_view_auth) == "group"): ?>active<?php endif; ?>" data-value="group"><?php echo L('GROUP');?></div><?php endif; ?>

				<?php if(!empty($isCustomerAllViewAuth)): ?><div class="customer-list-filter-option <?php if(($customer_view_auth) == "all"): ?>active<?php endif; ?>" data-value="all"><?php echo L('WHOLE');?></div><?php endif; ?>

			</div>

			<?php if(is_array($customerFilterlist)): $i = 0; $__LIST__ = $customerFilterlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="customer-list-filter select-fiter" data-type="highKeyword[define_form][<?php echo ($vo["form_name"]); ?>]">

					<div class="customer-list-filter-tit"><?php echo ($vo["form_description"]); ?></div>

					<?php if(is_array($vo["option"])): $i = 0; $__LIST__ = $vo["option"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><div class="customer-list-filter-checkbox <?php if(in_array($v,explode(',',$highKeyword['define_form'][$vo['form_name']]))): ?>active<?php endif; ?>" data-value="<?php echo ($v); ?>"><span class="iconfont <?php if(in_array($v,explode(',',$highKeyword['define_form'][$vo['form_name']]))): ?>icon-square-selected<?php else: ?>icon-weixuanzhong<?php endif; ?>"></span><?php echo ($v); ?></div><?php endforeach; endif; else: echo "" ;endif; ?>

				</div><?php endforeach; endif; else: echo "" ;endif; ?>

		</div>

	</div>

	<div class="feelcrm-list">

		<table class="layui-table" lay-skin="line">

			<thead>

				<tr>

					<th></th><th><?php echo L('CUSTOMER_NUMBER');?></th><th><?php echo L('CLIENT_NAME');?></th><th><?php echo L('TEL');?></th><th><?php echo L('CREATE_TIME');?></th>

				</tr>

			</thead>

			<tbody id="selectCustomer-detail">

				<?php if(empty($selectCustomer)): ?><tr class="nodata center">

						<td colspan="11">

							<p><i class="iconfont icon-nothing fts20"></i></p>

							<p><?php echo L('NO_DATA');?></p>

						</td>

					</tr>

				<?php else: ?>

					<?php if(is_array($selectCustomer)): $i = 0; $__LIST__ = $selectCustomer;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>

							<td><input type="radio" value="<?php echo ($vo["customer_id"]); ?>" data-name="<?php echo ($vo["detail"]["name"]); ?>" name="selectCustomer" lay-skin="primary" /></td>

							<td><?php echo ($vo["customer_prefix"]); echo ($vo["customer_no"]); ?></td>

							<td><?php echo ($vo["detail"]["name"]); ?></td>

							<td><?php echo ($vo["detail"]["phone"]); ?></td>

							<td><?php echo (getDates($vo["createtime"])); ?></td>

						</tr><?php endforeach; endif; else: echo "" ;endif; endif; ?>

			</tbody>

		</table>

		<div class="right-list-page clearfix"><div class="feeldesk-page"><?php echo ($selectCustomerPage); ?></div></div>

	</div>

</div>

<script>

	var selectActionUrl = '/<?php echo (CONTROLLER_NAME); ?>/<?php echo (ACTION_NAME); ?>';

	var selectAction = '<?php echo (ACTION_NAME); ?>';

	$('#selectCustomer').click(function(){

		var wHeight = $(window).height();

		wHeight = wHeight - 180 + 'px';

		var selectCustomercon = layer.open({
			type: 1,
			title: false,
			scrollbar:false,
			area: ['80%',wHeight],
			closeBtn:0,
			content: $('#selectCustomerCon')
		});

		var custfilternum = $('.customer-list-filter').length;

		var custlistHeight = $('#selectCustomerCon').height();

		if(custfilternum > 0)
		{
			var custfilterHeight = 45 * custfilternum;

			var custlistH = custlistHeight - 65 - custfilterHeight + 20;

			if($('.list-header').is(':hidden'))
			{
				custlistH = custlistH + 60;
			}

			$('#selectCustomerCon .feelcrm-list').css('height',custlistH - 20 +'px');
		}

		$('#selectCustomerCancel').click(function()
		{
			layer.close(selectCustomercon);
		})

		$('#selectCustomerSubmit').click(function()
		{
			var customer_id = $('input[name="selectCustomer"]:checked').val();

			var customer_name = $('input[name="selectCustomer"]:checked').attr('data-name');

			$('#selectCustomerInput').val(customer_id);

			$('#selectCustomerInput').attr('title',customer_name);

			layui.use('form', function() {

				var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

				form.render('radio');

			});

			if(selectAction == 'create_follow')
			{
				$.ajax({
					url:"<?php echo U('AjaxRequest/getContacter');?>",
					type:'POST',
					async: false,
					data:{'customer_id':customer_id},
					datatype:'json',
					success:function(data)
					{

						$('#ContacterList').html(data.html);

						layui.use('form', function() {

							var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

							form.render('select');

						});

						$('#ContacterList').parent().removeClass('hidden');
					},
					error:function()
					{

					}
				});
			}

			if(selectAction == 'create_contacter')
			{
				$.ajax({
					url:"<?php echo U('AjaxRequest/getContacter');?>",
					type:'POST',
					async: false,
					data:{'customer_id':customer_id},
					datatype:'json',
					success:function(data)
					{

						$('#ContacterList').html(data.html);

						$("#ContacterList").select2();
					},
					error:function()
					{

					}
				});
			}

			if(selectActionUrl == '/Contract/create')
			{
				$.ajax({
					url:"<?php echo U('AjaxRequest/getOpportunity');?>",
					type:'POST',
					async: false,
					data:{'customer_id':customer_id},
					datatype:'json',
					success:function(data)
					{
						$('#OpportunityList').html(data.html);

						$("#OpportunityList").select2();

						$("#OpportunityList").change(function ()
						{
							var opportunity_id = $(this).val();

							$('#chooseProList').html('');

							//选择商机后，更新合同金额及展示产品
							$.ajax({
								url:"<?php echo U('AjaxRequest/selectOpportunity');?>",
								type:'POST',
								async: false,
								data:{'opportunity_id':opportunity_id},
								datatype:'json',
								success:function(data)
								{
									$('#chooseProList').append(data.html);

									$.each($('input[name="product[]'),function(){

										var val = $(this).val();

										if($.inArray(val,data.product) != -1)
										{
											$(this).attr("checked","checked");

											layui.form.render();
										}

									});

									$(".proUnitPrice").bind("change",function(){
										countPrice(this);
									})

									$(".proContractNum").bind("change",function(){
										countPrice(this);
									})

									proKey = data.proKey;
								}
							});
						})
					}
				});
			}

			if($.inArray(selectActionUrl,['/Account/create','/Receipt/create','/Invoice/create','/Account/index','/Receipt/index','/Invoice/index']) != -1)
			{
				$.ajax({
					url:"<?php echo U('AjaxRequest/getContract');?>",
					type:'POST',
					async: false,
					data:{'customer_id':customer_id,'type':'option'},
					datatype:'json',
					success:function(data)
					{
						$('#contractList').html(data.html);

						layui.use('form', function() {

							var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

							form.render('select');

						});
					}
				});

				if(selectActionUrl == '/Invoice/create')
				{
					$.ajax({
						url:"<?php echo U('AjaxRequest/getCustomerInvoiceInfo');?>",
						type:'POST',
						async: false,
						data:{'customer_id':customer_id},
						datatype:'json',
						success:function(data)
						{
							$('#InvoiceInfoList').html(data.html);

							layui.use('form', function() {

								var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

								form.render('select');

							});
						}
					});
				}
			}

			/*if(selectActionUrl == '/Order/create')
			{
				$.ajax({
					url:"<?php echo U('AjaxRequest/getContract');?>",
					type:'POST',
					async: false,
					data:{'customer_id':customer_id},
					datatype:'json',
					success:function(data)
					{
						$('#selectContract span').html("<?php echo L('SELECT_ASSOCIATED_CONTRACT');?>");

						$('#contractList').hide();

						$('#contractList').html(data.html);

						$("#selectContract").unbind('click').on('click',function()
						{
							var checkbox = $(this);

							$(this).toggleClass('feeldesk-form-checked').next('.feeldesk-option-panel').slideToggle('fast');

							$(this).parents('.feeldesk-form-item').siblings().find('.feeldesk-input').removeClass('feeldesk-form-checked').next('.feeldesk-option-panel').slideUp('fast');

							$(".checkboxPanel").find('li').on('click',function()
							{
								var value = $(this).data('value');

								$(this).find('span.iconfont').toggleClass('icon-xuanze');

								$(this).find('span.iconfont').toggleClass('icon-xuanzhong');

								var oldValue = checkbox.find('span').text();

								var content = '';

								if($(this).find('span.iconfont').hasClass('icon-xuanzhong'))
								{
									$(this).find("input").prop('checked',true);

									content = addContent(oldValue,value);
								}
								else
								{
									$(this).find("input").prop('checked',false);

									content = removeContent(oldValue,value);
								}

								$(this).parent('.checkboxPanel').prev('.checkbox').find('span').text(content);
							});
						});


					},
					error:function()
					{

					}
				});
			}

			if(selectActionUrl == '/Contract/create')
			{
				$.ajax({
					url:"<?php echo U('AjaxRequest/getOrder');?>",
					type:'POST',
					async: false,
					data:{'customer_id':customer_id},
					datatype:'json',
					success:function(data)
					{
						$('#selectOrder span').html('请选择关联订单');

						$('#orderList').hide();

						$('#orderList').html(data.html);

						$("#selectOrder").unbind('click').on('click',function()
						{
							var checkbox = $(this);

							$(this).toggleClass('feeldesk-form-checked').next('.feeldesk-option-panel').slideToggle('fast');

							$(this).parents('.feeldesk-form-item').siblings().find('.feeldesk-input').removeClass('feeldesk-form-checked').next('.feeldesk-option-panel').slideUp('fast');

							$(".checkboxPanel").find('li').on('click',function()
							{
								var value = $(this).data('value');

								$(this).find('span.iconfont').toggleClass('icon-xuanze');

								$(this).find('span.iconfont').toggleClass('icon-xuanzhong');

								var oldValue = checkbox.find('span').text();

								var content = '';

								if($(this).find('span.iconfont').hasClass('icon-xuanzhong'))
								{
									$(this).find("input").prop('checked',true);

									content = addContent(oldValue,value);
								}
								else
								{
									$(this).find("input").prop('checked',false);

									content = removeContent(oldValue,value);
								}

								$(this).parent('.checkboxPanel').prev('.checkbox').find('span').text(content);
							});
						});


					},
					error:function()
					{

					}
				});
			}*/

			layer.close(selectCustomercon);

		})
	})

	$('.select-fiter .customer-list-filter-option').on('click',function ()
	{
		var type = $(this).parent().data('type');

		var value = $(this).data('value');

		$(this).addClass('active').siblings().removeClass('active');

		$("input[name='"+type+"']").val(value);

		searchCustomer();
	})

	$('.select-fiter .customer-list-filter-checkbox span').on('click',function ()
	{
		var type = $(this).parent().parent().data('type');

		//var value = $(this).parent().data('value');

		if($(this).hasClass('icon-square-selected'))
		{
			$(this).removeClass('icon-square-selected').addClass('icon-weixuanzhong');
			$(this).parent().removeClass('active');
		}
		else
		{
			$(this).removeClass('icon-weixuanzhong').addClass('icon-square-selected');
			$(this).parent().addClass('active');
		}

		var value = [];

		var check = $(this).parent().parent().find('.customer-list-filter-checkbox.active');

		check.each(function()
		{
			value.push($(this).attr('data-value'));
		});

		value = value.toString();

		if(!value) value = '';

		$("input[name='"+type+"']").val(value);

		searchCustomer();
	})

	function selectCustomerPage(obj,selectActionUrl)
	{
		var href = $(obj).attr('href');

		var ajaxhref = href.replace(selectActionUrl, '/AjaxRequest/getCustomerList');

		$.ajax({
				url:ajaxhref,
				type:'POST',
				async: false,
				datatype:'json',
				success:function(data)
				{

					$('#selectCustomer-detail').html(data.html);

					$('#selectCustomerCon .feeldesk-page').html(data.page);

					layui.use('form', function() {

						var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

						form.render();

					});

					$('#selectCustomerCon .feeldesk-page a').click(function()
					{
						selectCustomerPage(this);

						return false;
					})

				},
				error:function()
				{
				   layer.msg("<?php echo L('FAILED_TO_ACQUIRE_CUSTOMERS');?>");
				}
		 });
	}

	$('#selectCustomerCon .feeldesk-page a').click(function()
	{
		selectCustomerPage(this,selectActionUrl);

		return false;
	})

	$('input[name="selectCustomerKeyword"]').keyup(function (e)
	{
		if (e.keyCode == 13)
		{
			searchCustomer();
		}
	});

	$('.selectCustomerBtn').unbind('click').bind('click',function(){

		searchCustomer();
	})

	function searchCustomer()
	{
		var keyword = $('input[name="selectCustomerKeyword"]').val();

		var importance = $('input[name="highKeyword[define_form][importance]"]').val();

		var customer_grade = $('input[name="highKeyword[define_form][customer_grade]"]').val();

		var customer_auth = $('input[name="customer_auth"]').val();

		var highKeyword ={
			'define_form':{'importance':importance,'customer_grade':customer_grade}
		};

		$.ajax({
				url:"<?php echo U('AjaxRequest/getCustomerList');?>",
				type:'get',
				data:{'keyword':keyword,'highKeyword':highKeyword,'customer_auth':customer_auth},
				async: false,
				datatype:'json',
				success:function(data)
				{
					$('#selectCustomer-detail').html(data.html);

					$('#selectCustomerCon .feeldesk-page').html(data.page);

					layui.use('form', function() {

						var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

						form.render();

					});

					$('#selectCustomerCon .feeldesk-page a').click(function()
					{
						selectCustomerPage(this);

						return false;
					})

				},
				error:function()
				{
				   layer.msg("<?php echo L('FAILED_TO_ACQUIRE_CUSTOMERS');?>");
				}
		 });

		return false;
	}

</script>


    <script type="text/javascript" src="/Public/js/submitform.js"></script>
<script type="text/javascript">
	
	layui.use('form',function()
	{
		var form = layui.form;
		
		form.render('checkbox');
		
		form.render('radio');
		
		form.render('select');

	})
	
</script>


    <script type="text/javascript">

        $("#choose").hide();

        layui.use('form',function()
        {
            var form = layui.form;

            form.on('select(form_type)', function(data)
            {
                var type = data.value;

                if(type == 'radio' || type == 'checkbox' || type == 'select')
                {
                    $("#choose").slideDown(300);
                }
                else
                {
                    $("#choose").slideUp(300);
                }
            });
        })

		function createNewcontacter()
		{
			$('input[name="editContacterWechat"]').val('0');

			$('.wechatbox').addClass('hidden');

			$('.contacterdefine').removeClass('hidden');
		}

    </script>



    </div>

    <script type="text/javascript">

        layer.ready(function()
        {
            layer.photos({
                photos: '.textareaImg',
                shift: 5,
                shade: [0.8, 'rgba(0,0,0,.8)']
            });

        })

    </script>

    <script>

        //客户端
        /*if ( navigator.userAgent.toLowerCase().indexOf('electron/') > -1)
        {
            top.setIframe(document);
        }*/
    </script>

    </body>

</html>